﻿using System;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.nodes.teradata;

namespace SharpSqlAnalyzer.stmt.teradata
{
	// Token: 0x020000CF RID: 207
	public class TTeradataCreateMacro : TStoredProcedureSqlStatement
	{
		// Token: 0x17000159 RID: 345
		// (get) Token: 0x0600075E RID: 1886 RVA: 0x00300821 File Offset: 0x002FEA21
		// (set) Token: 0x0600075F RID: 1887 RVA: 0x00300829 File Offset: 0x002FEA29
		public TParameterDeclarationList parameters
		{
			get
			{
				return this._parameters;
			}
			set
			{
				this._parameters = value;
			}
		}

		// Token: 0x1700015A RID: 346
		// (get) Token: 0x06000760 RID: 1888 RVA: 0x00300832 File Offset: 0x002FEA32
		// (set) Token: 0x06000761 RID: 1889 RVA: 0x0030083A File Offset: 0x002FEA3A
		public TStatementListSqlNode stmts
		{
			get
			{
				return this._stmts;
			}
			set
			{
				this._stmts = value;
			}
		}

		// Token: 0x1700015B RID: 347
		// (get) Token: 0x06000762 RID: 1890 RVA: 0x00300843 File Offset: 0x002FEA43
		// (set) Token: 0x06000763 RID: 1891 RVA: 0x0030084B File Offset: 0x002FEA4B
		public TObjectName macroName
		{
			get
			{
				return this._macroName;
			}
			set
			{
				this._macroName = value;
			}
		}

		// Token: 0x06000764 RID: 1892 RVA: 0x00300854 File Offset: 0x002FEA54
		public override void init(object arg1, object arg2)
		{
			this._macroName = (TObjectName)arg1;
			this._stmts = (TStatementListSqlNode)arg2;
		}

		// Token: 0x06000765 RID: 1893 RVA: 0x0030086E File Offset: 0x002FEA6E
		public TTeradataCreateMacro(EDbVendor dbvendor) : base(dbvendor)
		{
			this.sqlstatementtype = ESqlStatementType.sstteradatacreatemacro;
		}

		// Token: 0x06000766 RID: 1894 RVA: 0x00300884 File Offset: 0x002FEA84
		public override int doParseStatement(TCustomSqlStatement psql)
		{
			if (this.rootNode == null)
			{
				return -1;
			}
			base.doParseStatement(psql);
			TTeradataCreateMacroSqlNode tteradataCreateMacroSqlNode = (TTeradataCreateMacroSqlNode)this.rootNode;
			this.macroName = tteradataCreateMacroSqlNode.macroName;
			base.DatabaseObjects.Add(this.macroName);
			this.parameters = tteradataCreateMacroSqlNode.parameters;
			if (this.parameters != null)
			{
				for (int i = 0; i < this.parameters.size(); i++)
				{
					this.TopStatement.SymbolTable.Push(new TSymbolTableItem(9, this, this.parameters.getParameterDeclarationItem(i)));
				}
			}
			TStatementListSqlNode stmts = tteradataCreateMacroSqlNode.stmts;
			stmts.doParse(this, ESqlClause.unknown);
			for (int j = 0; j < stmts.size(); j++)
			{
				this.BodyStatements.add(stmts.getStatementSqlNode(j).Stmt);
			}
			if (this.parameters != null)
			{
				for (int k = 0; k < this.parameters.size(); k++)
				{
					this.TopStatement.SymbolTable.Pop();
				}
			}
			return 0;
		}

		// Token: 0x06000767 RID: 1895 RVA: 0x00300985 File Offset: 0x002FEB85
		public override void accept(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x06000768 RID: 1896 RVA: 0x00300995 File Offset: 0x002FEB95
		public override void acceptChildren(TParseTreeVisitor v)
		{
			v.preVisit(this);
			v.postVisit(this);
		}

		// Token: 0x040011DF RID: 4575
		private TParameterDeclarationList _parameters;

		// Token: 0x040011E0 RID: 4576
		private TStatementListSqlNode _stmts;

		// Token: 0x040011E1 RID: 4577
		private TObjectName _macroName;
	}
}
